﻿using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace _11._21._2014_AngularWebAPI.Extensions
{
    public static class FirebaseHelper
    {
        public static IDictionary<string, object> ToFirebaseResult<T, TValue>(this List<T> items, Expression<Func<T, TValue>> key) where T : class
        {
            IDictionary<string, object> jsonObj = new ExpandoObject();
            items.ForEach(m => jsonObj[ExpressionHelper.GetExpressionText(key)] = m);
            return jsonObj;
        }
    }
}